package containerlogistik.implementation;

import java.math.BigDecimal;

final class DoubleUtils {

    /**
     * Returns the rounded double value of an unrounded double value.
     *
     * @param unrounded the unrounded double value
     * @param precision the precision of the rounded double value
     * @return rounded double value
     */
    public static double round(double unrounded, int precision) {
        BigDecimal bd = new BigDecimal(unrounded);
        BigDecimal rounded = bd.setScale(precision, BigDecimal.ROUND_HALF_UP);
        return rounded.doubleValue();
    }
}
